<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户提现记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>用户id：</p>
                            <input type="text" name="userId"/>
                        </li>
                        <li>
                            <p>提现方式：</p>
                            <select name="withdrawWay">
                                <option value="">所有</option>
                                <option th:value="1">微信</option>
                                <option th:value="2">支付宝</option>
                            </select>
                        </li>
                        <li>
                            <p>提现金额：</p>
                            <input type="text" name="withdrawGold"/>
                        </li>
                        <li>
                            <p>提现账户：</p>
                            <input type="text" name="withdrawAccount"/>
                        </li>
                        <li>
                            <p>提现状态：</p>
                            <select name="withdrawStatus">
                                <option value="">所有</option>
                                <option value="0">审核不通过</option>
                                <option value="1">审核中</option>
                                <option value="2">审核通过</option>
                                <option value="3">已打款</option>
                            </select>
                        </li>
                        <!--<li class="select-time">
                            <p>提现时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginWithdrawTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endWithdrawTime]"/>
                        </li>-->
                        <li>
                            <p>拒绝原因：</p>
                            <input type="text" name="withdrawCause"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
           <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:record:add">
                <i class="fa fa-plus"></i> 添加
            </a>-->
            <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:record:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:record:remove">
                <i class="fa fa-remove"></i> 删除
            </a>-->
            <a class="btn btn-info" onclick="selectColumns()" shiro:hasPermission="system:record:edit">
                <!--                <i class="fa fa-search"></i> -->快速审核(✔)
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:record:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<!--模态框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">提现拒绝</h4>
            </div>
            <!-- 下两个是上个页面传递出来的参数 -->
            <input id="applyForId" value="" text="text" style="display: none">
            <input id="applyUserId" value="" text="text" style="display: none">
            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <div class="form-horizontal m" id="form-task-edit">
                    <!--                         <div class="form-group">-->
                    <!--                             <label class="col-sm-3 control-label">扣除金额：</label>-->
                    <!--                             <div class="col-sm-8">-->
                    <!--                                 <input name="deduct" class="form-control" type="text" required>-->
                    <!--                             </div>-->
                    <!--                         </div>-->
                    <div class="form-group">
                        <label class="col-sm-3 control-label">拒绝理由：</label>
                        <div class="col-sm-8">
                            <input id="withdrawCause" name="withdrawCause" class="form-control" type="text" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary button" id="button">提交更改</button>
                    </div>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:record:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:record:remove')}]];
    var prefix = ctx + "app/withdrawrecord";
    var refuse = ctx + "app/withdrawrecord/edit"

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "用户提现记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'withdrawId',
                    title: '提现记录表主键',
                    visible: false
                },
                {
                    field: 'userId',
                    title: '用户id'
                },
                {
                    field: 'withdrawWay',
                    title: '提现方式',
                    formatter: function (value, row, index) {
                        if (value == 1) {
                            return "微信"
                        } else {
                            return "支付宝"
                        }
                    }

                },
                {
                    field: 'withdrawGold',
                    title: '提现金额'
                },
                {
                    field: 'withdrawAccount',
                    title: '提现账户'
                },
                {
                    field: 'withdrawStatus',
                    title: '提现状态',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "审核不通过"
                        } else if (value == 1) {
                            return "审核中"
                        } else if (value == 2) {
                            return "审核通过"
                        } else if (value == 3) {
                            return "已打款"
                        }
                    }
                },
                {
                    field: 'withdrawCause',
                    title: '拒绝原因'
                },
                {
                    field: 'withdrawTime',
                    title: '提现时间'
                },
                {
                    field: 'updateTime',
                    title: '审核时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var withdrawStatus = row.withdrawStatus;
                       /* actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.withdrawId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.withdrawId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                       if (withdrawStatus == 1){
                           actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="pass(\'' + row.withdrawId + '\')">通过</a> ');
                           actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '  "data-toggle="modal" data-target="#myModal" onclick="ces(' + row.withdrawId +')">拒绝</a> ');
                       }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function selectColumns() {
        var column = $.table.selectColumns('withdrawId');

        if (column.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要审核提现成功选中的" + column.length + "条数据吗?", function () {
            var url = ctx + "app/withdrawrecord/batchAudit";
            var data = {"ids": column.join()};
            // debugger;
            $.operate.submit(url, "post", "json", data);
        });
        // alert(column);
    }

    function pass(withdrawId) {
        $.modal.confirm("确认提现通过申请吗?",function () {
            $.operate.post(prefix+"/edit",{"withdrawId":withdrawId,"withdrawStatus":2});
        })
    }

    //点击按钮时赋值给模态框里的input框赋值
    function ces(withdrawId) {
        $("#applyForId").val(withdrawId);
    }

    //模态框中的提交
    $("#button").click(function () {
        $.operate.post(prefix + "/edit", {
            "withdrawId": $("#applyForId").val(),
            "withdrawCause": $("#withdrawCause").val(),
            "withdrawStatus": 0
        });
        $("#myModal").modal('hide')
        $.modal.alert("已完成");
    })
</script>
</body>
</html>